Imports System.Data.SqlClient
Public Class Profesional : Implements IBusquedaFiltrado
    Private matricula As Integer
    Private tipodoc As TipoDocumento
    Private nrodoc As String
    Private apenom As String
    Private calle As String
    Private nro As Integer
    Private piso As String
    Private dpto As String
    Private idbarrio As Barrio
    Private especialidad As String

    '***AGENDA****
    Private DiaA As String
    Private hsdesde As String
    Private hshasta As String
    Public Property dia() As String
        Get
            Return DiaA
        End Get
        Set(ByVal value As String)
            DiaA = value
        End Set
    End Property
    Public Property Hdesde() As String
        Get
            Return hsdesde
        End Get
        Set(ByVal value As String)
            hsdesde = value
        End Set
    End Property
    Public Property Hhasta() As String
        Get
            Return hshasta
        End Get
        Set(ByVal value As String)
            hshasta = value
        End Set
    End Property
    'Private lunes As String
    'Private martes As String
    'Private miercoles As String
    'Private jueves As String
    'Private viernes As String
    'Private sabado As String

    'Public Property lun() As String
    '    Get
    '        Return lunes
    '    End Get
    '    Set(ByVal value As String)
    '        lunes = value
    '    End Set
    'End Property
    'Public Property mar() As String
    '    Get
    '        Return martes
    '    End Get
    '    Set(ByVal value As String)
    '        martes = value
    '    End Set
    'End Property
    'Public Property mie() As String
    '    Get
    '        Return miercoles
    '    End Get
    '    Set(ByVal value As String)
    '        miercoles = value
    '    End Set
    'End Property
    'Public Property jue() As String
    '    Get
    '        Return jueves
    '    End Get
    '    Set(ByVal value As String)
    '        jueves = value
    '    End Set
    'End Property
    'Public Property vie() As String
    '    Get
    '        Return viernes
    '    End Get
    '    Set(ByVal value As String)
    '        viernes = value
    '    End Set
    'End Property
    'Public Property sab() As String
    '    Get
    '        Return sabado
    '    End Get
    '    Set(ByVal value As String)
    '        sabado = value
    '    End Set
    'End Property
    Public Property MatriculaProf() As Integer
        Get
            Return matricula
        End Get
        Set(ByVal value As Integer)
            matricula = value
        End Set
    End Property
    Public Property tipodocProf() As TipoDocumento
        Get
            Return tipodoc
        End Get
        Set(ByVal value As TipoDocumento)
            tipodoc = value
        End Set
    End Property
    Public Property nrodocProf() As String
        Get
            Return nrodoc
        End Get
        Set(ByVal value As String)
            nrodoc = value
        End Set
    End Property
    Public Property apenomProf() As String
        Get
            Return apenom
        End Get
        Set(ByVal value As String)
            apenom = value
        End Set
    End Property
    Public Property calleProf() As String
        Get
            Return calle
        End Get
        Set(ByVal value As String)
            calle = value
        End Set
    End Property
    Public Property nroProf() As Integer
        Get
            Return nro
        End Get
        Set(ByVal value As Integer)
            nro = value
        End Set
    End Property
    Public Property pisoProf() As String
        Get
            Return piso
        End Get
        Set(ByVal value As String)
            piso = value
        End Set
    End Property
    Public Property dptoProf() As String
        Get
            Return dpto
        End Get
        Set(ByVal value As String)
            dpto = value
        End Set
    End Property
    Public Property IdBarrioProf() As Barrio
        Get
            Return idbarrio
        End Get
        Set(ByVal value As Barrio)
            idbarrio = value
        End Set
    End Property
    Public Property especialidadProf() As String
        Get
            Return especialidad
        End Get
        Set(ByVal value As String)
            especialidad = value
        End Set
    End Property

    Public Function Agregar(ByRef con As ConexionBD) As Boolean Implements IBusquedaFiltrado.Agregar
        Return True
    End Function

    Public Function Buscar(ByVal id As Integer, ByRef con As ConexionBD) As Boolean Implements IBusquedaFiltrado.Buscar
        Dim comando As SqlDataAdapter
        Dim rs As DataTableReader
        Dim dato As DataTable
        Dim sql As String
        Dim lResp As Boolean = False

        sql = String.Format("SELECT * FROM PROFESIONAL WHERE MATRICULA ={0}", id)
        comando = New SqlDataAdapter(sql, con.ConexionBase)
        dato = New DataTable("profesional")
        comando.Fill(dato)
        rs = dato.CreateDataReader()
        comando.Dispose()
        dato.Dispose()

        If rs.Read Then
            matricula = rs("matricula")
            Dim ObjTipoDocProf As TipoDocumento = New TipoDocumento
            ObjTipoDocProf.Buscar(rs("idtipodoc"), con)
            tipodocProf = ObjTipoDocProf
            nrodoc = rs("nrodoc")
            apenom = rs("apenom")
            calle = rs("calle")
            nro = rs("nro")
            piso = rs("piso")
            dpto = rs("dpto")
            Dim ObjBarr As Barrio = New Barrio()
            ObjBarr.Buscar(rs("IdBarrio"), con)
            IdBarrioProf = ObjBarr
            especialidad = rs("especialidad")
            lResp = True
        Else
            lResp = False
        End If
        rs.Close()
        Return lResp

    End Function
    Public Function BuscarProf(ByVal profes As String, ByRef con As ConexionBD) As Boolean
        Dim comando As SqlDataAdapter
        Dim rs As DataTableReader
        Dim dato As DataTable
        Dim sql As String
        Dim lResp As Boolean = False

        sql = String.Format("SELECT * FROM PROFESIONAL WHERE APENOM ='{0}'", profes)
        comando = New SqlDataAdapter(sql, con.ConexionBase)
        dato = New DataTable("profesional")
        comando.Fill(dato)
        rs = dato.CreateDataReader()
        comando.Dispose()
        dato.Dispose()

        If rs.Read Then
            matricula = rs("matricula")
            Dim ObjTipoDocProf As TipoDocumento = New TipoDocumento
            ObjTipoDocProf.Buscar(rs("idtipodoc"), con)
            tipodocProf = ObjTipoDocProf
            nrodoc = rs("nrodoc")
            apenom = rs("apenom")
            calle = rs("calle")
            nro = rs("nro")
            piso = rs("piso")
            dpto = rs("dpto")
            Dim ObjBarr As Barrio = New Barrio()
            ObjBarr.Buscar(rs("IdBarrio"), con)
            IdBarrioProf = ObjBarr
            especialidad = rs("especialidad")
            'lun = rs("lunes")
            'mar = rs("martes")
            'mie = rs("miercoles")
            'jue = rs("jueves")
            'vie = rs("viernes")
            'sab = rs("sabado")
            lResp = True
        Else
            lResp = False
        End If
        rs.Close()
        Return lResp

    End Function
    Public Function BuscarAgenda(ByVal mat As Integer, ByRef con As ConexionBD) As DataSet
        Dim datos As DataSet = New DataSet()
        Dim adapter As SqlDataAdapter
        Dim sql As String = ""
        sql = String.Format("SELECT * FROM AGENDAPROFESIONAL WHERE MATRICULA ={0}", mat)
        sql = String.Format(sql, mat)
        adapter = New SqlDataAdapter(sql, con.ConexionBase)
        adapter.Fill(datos, "agendaprofesional")
        Return datos
    End Function
    Public Function Eliminar(ByVal id As Integer, ByRef con As ConexionBD) As Boolean Implements IBusquedaFiltrado.Eliminar
        Return True
    End Function

    Public Function Modificar(ByRef con As ConexionBD) As Boolean Implements IBusquedaFiltrado.Modificar
        Return True
    End Function

    Public Sub New()
        matricula = 0
        tipodoc = Nothing
        nrodoc = ""
        apenom = ""
        calle = ""
        nro = 0
        piso = ""
        dpto = ""
        idbarrio = Nothing
        especialidad = ""
        DiaA = ""
        hsdesde = ""
        hshasta = ""
        'lunes = ""
        'martes = ""
        'miercoles = ""
        'jueves = ""
        'viernes = ""
        'sabado = ""
    End Sub
    Public Function BuscarDatos(ByRef con As ConexionBD) As DataSet

        Dim sql As String = ""
        Dim adapter As SqlDataAdapter = Nothing
        Dim datos As DataSet = New DataSet()

        sql = "SELECT * FROM PROFESIONAL"
        adapter = New SqlDataAdapter(sql, con.ConexionBase)
        adapter.Fill(datos, "profesional")

        Return datos
    End Function

End Class
